package com.ljx.itbbs.server.article.dao;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ljx.itbbs.server.article.domain.entity.LikeRecordEntity;
import com.ljx.itbbs.server.article.mapper.LikeRecordMapper;
import org.springframework.stereotype.Service;

@Service
public class LikeRecordDao extends ServiceImpl<LikeRecordMapper, LikeRecordEntity> {

    public LikeRecordEntity getLikeRecord(String objKey, Long userId) {
        return lambdaQuery().eq(LikeRecordEntity::getLikeObj, objKey)
                .eq(LikeRecordEntity::getUserId, userId)
                .one();
    }

    public void deleteListRecord(Long userId, String likeObj, Integer type) {
        this.baseMapper.delete(new LambdaQueryWrapper<LikeRecordEntity>()
                .eq(LikeRecordEntity::getUserId, userId)
                .eq(LikeRecordEntity::getLikeObj, likeObj)
                .eq(LikeRecordEntity::getType, type));
    }
}
